// 封装所有与员工相关的接口
import instance from '@/utils/request'

// 获取员工基本信息
export function getBaseInfoApi(id) {
  return instance({
    url: `/sys/user/${id}`
  })
}

// 获取员工简单列表
export function getSimpleListApi() {
  return instance({
    url: '/sys/user/simple'
  })
}
// 获取员工列表
export function getEmployeesListApi(params) {
  return instance({
    url: '/sys/user',
    method: 'GET',
    params
  })
}

// 新增员工
export function addEmployeesApi(data) {
  return instance({
    url: '/sys/user',
    method: 'POST',
    data
  })
}

// 批量导入员工
export function importEmployeesApi(data) {
  return instance({
    url: '/sys/user/batch',
    method: 'POST',
    data
  })
}

// 保存员工基本信息
export function saveBaseInfoApi(data) {
  return instance({
    url: `/sys/user/${data.id}`,
    method: 'PUT',
    data
  })
}


// 获取员工个人信息
export function getPersonalInfoApi(id) {
  return instance({
    url: `/employees/${id}/personalInfo`,

  })
}

// 保存员工个人信息
export function savePersonalInfoApi(data) {
  return instance({
    url: `/employees/${data.userId}/personalInfo`,
    method: 'PUT',
    data
  })
}

// 获取员工岗位信息
export function getJobInfoApi(id) {
  return instance({
    url: `/employees/${id}/jobs`
  })
}

// 保存员工岗位信息
export function saveJobInfoApi(data) {
  return instance({
    url: `/employees/${data.userId}/jobs`,
    method: 'PUT',
    data
  })
}

// 给员工分配角色
export function setRoleApi(data) {
  return instance({
    url: '/sys/user/assignRoles',
    method: 'PUT',
    data
  })
}
